import { defineStore } from "pinia";
import { defaultSettings } from "../../../defaultSetting.ts";
// 导入 Element Plus 中英文语言包
import zhCn from "element-plus/es/locale/lang/zh-cn";
import en from "element-plus/es/locale/lang/en";

export const useAppStore = defineStore("app", () => {
  // 语言类型
  const language = useStorage("language", defaultSettings.language);
  const changeLanguage = (val: string) => {
    language.value = val;
  };

  const locale = computed(() => {
    return language.value === "zh-cn" ? zhCn : en;
  });
  // 组件大小
  const size = useStorage("size", defaultSettings.size);
  const changeSize = (val: string) => {
    size.value = val;
  }
  return {
    language,
    changeLanguage,
    locale,
    size,
    changeSize
  }
});